package com.hqq.create.prototype;

import java.io.IOException;

/**
 * PrototypeTest
 * Created by heqianqian on 2017/3/10.
 */
public class PrototypeTest {
    public static void main(String[] args) throws CloneNotSupportedException, IOException, ClassNotFoundException {

        Prototype prototype = new Prototype();
        prototype.setString("heqianqian");
        prototype.setObj(new SerializableObject());

        /*浅复制*/
        Prototype p2 = (Prototype) prototype.clone();
        System.out.println(p2.getString());
        System.out.println(p2.getString()==prototype.getString());
        System.out.println(p2.getObj()==prototype.getObj());

        /*深复制*/
        Prototype p3 = (Prototype) prototype.deepClone();
        System.out.println(p3.getString());
        System.out.println(p3.getString()==prototype.getString());
        System.out.println(p3.getObj()==prototype.getObj());
    }
}
